﻿using System.Drawing;
using System.Windows.Forms;
using CloudShot.Utils;

namespace CloudShot.Controls
{
  public class ColorRadioButton : RadioButton
  {
    public Color Color { get; set; }

    protected override void OnPaint(PaintEventArgs paintArgs)
    {
      base.OnPaint(paintArgs);
      
      const int colorBorderWidth = 1;

      Color borderColor = Color.AdjustBrightness(0.5f);
      Rectangle rect = ClientRectangle.ApplyPadding(Padding);

      Graphics graphics = paintArgs.Graphics;

      using (var pen = new Pen(borderColor, colorBorderWidth))
      using (var brush = new SolidBrush(Color))
      {
        graphics.FillRectangle(brush, rect);

        rect.Width -= colorBorderWidth;
        rect.Height -= colorBorderWidth;

        graphics.DrawRectangle(pen, rect);
      }
    }
  }
}